var scanCode = function() {
    window.plugins.barcodeScanner.scan(
        function(result) {
        //alert("Scanned Code: " + result.text 
         //       + ". Format: " + result.format
         //       + ". Cancelled: " + result.cancelled);
        barcode = result.text;
		alert("qr-tag gefunden");
		if(barcode.length >= 2){
			window.open('http://ambrella.dyndns.org:8400/blazeds/ambrella_flex/test123.html', 'Login', 'window settings')

		}else{
			alert("QR-Tag nicht gefunden");
			//$.mobile.changePage("index.html", "slide");
		}
    }, function(error) {
        alert("Scan failed: " + error);
    });
}

var encodeText = function() {
    window.plugins.barcodeScanner.encode(
            BarcodeScanner.Encode.TEXT_TYPE,
            "http://www.mobiledevelopersolutions.com", 
            function(success) {
                alert("Encode success: " + success);
            }, function(fail) {
                alert("Encoding failed: " + fail);
            });
}

var encodeEmail = function() {
    window.plugins.barcodeScanner.encode(
        BarcodeScanner.Encode.EMAIL_TYPE,
        "a.name@gmail.com", function(success) {
            alert("Encode success: " + success);
        }, function(fail) {
            alert("Encoding failed: " + fail);
        });
}

var encodePhone = function() {
    window.plugins.barcodeScanner.encode(
        BarcodeScanner.Encode.PHONE_TYPE,
        "555-227-5283", function(success) {
            alert("Encode success: " + success);
        }, function(fail) {
            alert("Encoding failed: " + fail);
        });
}

var encodeSMS = function() {
    window.plugins.barcodeScanner.encode(
        BarcodeScanner.Encode.SMS_TYPE,
        "An important message for someone.", function(success) {
            alert("Encode success: " + success);
        }, function(fail) {
            alert("Encoding failed: " + fail);
        });
}